<#include "../inc/header.ftl" />
<div class="admin-content">
    <ui id="error" class="message error" style="display:none;"></ui>
    <form id="dailyForm" name="dailyForm" method="post" action="${base}/admin/daily/edit/do">
        <input type="hidden" name="id" value="${daily.id}"/>
        <input type="hidden" name="format" id="format" value="${daily.format}"/>
        <input type="hidden" name="imageList" id="imageList"
               value="<#if daily.imageList?has_content>${daily.imageList?xhtml}</#if>"/>
        <table class="formtable">
            <tr>
                <td class="label" style="width: 100px;">标题</td>
                <td class="field" colspan="3"><input type="text" class="textinput" name="title" value="${daily.title}"/></td>
            </tr>
            <tr>
                <td colspan="4">
                <#include "daily-image.ftl" />
                </td>
            </tr>
            <tr>
                <td class="field" colspan="4">
                    <#if daily.format == 'html'>
                        <!-- html编辑器 -->
                        <script type="text/javascript" src="${base}/static/js/kindeditor/kindeditor-all-min.js"></script>
                        <textarea id="content" name="content" style="width:99%;height:680px;">${daily.content!""}</textarea>
                        <script>
                            $(document).ready(function () {
                                admin.htmlEditor = admin.editor.html('content');
                            });
                        </script>
                    <#else>
                        <!-- markdown编辑器 -->
                        <link rel="stylesheet" href="${base}/static/js/editor.md/css/editormd.css" />
                        <script type="text/javascript" src="${base}/static/js/editor.md/editormd.min.js"></script>
                        <div id="content">
                            <textarea id="markdownContent" name="content" style="display: none;">${daily.content!""}</textarea>
                        </div>
                        <script>
                            $(document).ready(function () {
                                admin.markdownEditor = admin.editor.markdown('content');
                            });
                        </script>
                    </#if>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="toolbar">
                    <input class="btn btn-default" type="submit" value="提交表单"/>
                </td>
            </tr>
        </table>
    </form>
</div>
<script type="text/javascript" src="${base}/static/js/jquery-tagsinput/jquery.tagsinput.min.js"></script>
<link rel="stylesheet" href="${base}/static/js/jquery-tagsinput/jquery.tagsinput.css"/>

<script type="text/javascript">
    $(document).ready(function () {
        admin.daily.validateForm();
    });

    // markdown预览
    function markdownPreview() {
        var content = $('#content').val();
        httpPost('/admin/daily/markdown/preview', {'content': content}, function (data) {
            var obj = window.open("about:blank");
            obj.document.write(data);
        });
    }
</script>
<#include "../inc/footer.ftl" />